# -*- coding:utf-8 -*-
'''
    This file use prop model with different error level. 
    To evaluate the state evolution of satellite's with differeent error level
''' 
from aod.satellite import *
import dataread
from aod.satProp import *
import aod 
noiseLevels = [8]
for noiseLevel in noiseLevels:
    for experiment in range(1,100):
        libOrbitProp = cdll.LoadLibrary('./aod/PropagateDLL_'+str(noiseLevel)+'.dll')

        data = dataread.dataRead()
        data.fetchdata()
        loadProgressFile = './data/progressData/defaultprogress.data'
        progressData =  data.readProgressData(loadProgressFile)

        iterationNum =  50000
        satCurrentTime  = 307627203 

        sats = []
        for i in range(0,1):
            satInitState =     progressData['satInitState'][i]
            # satInitKineMean  = np.array((16983352.634205 ,    -20353708.086466        ,    -6.183084 ,      1709.449900   ,    1426.384892     ,  3179.607493),dtype=float)
            satInitKineMean    = np.array(data.initialData[i][1:7],dtype=float)
            satInitKineCov   = np.array(np.zeros((6,6)),dtype=float)
            # satInitKineCov  = np.array(DEFAULTINITPSE,dtype=float)
            satTimeDrift     = progressData['satTimeDrift'][i]
            satInitKineSate  = cStateWrapper(satInitKineMean,satInitKineCov)
            timeDrift        = cStateWrapper(np.array(satTimeDrift['mean'],dtype=float),np.array(satTimeDrift['cov'],dtype=float))

            sat              = cSat('sat'+str(i+1),satInitKineSate,timeDrift,propagator=libOrbitProp )
            sat.setCurTime(satCurrentTime)
            sat.recordFileLength = 10000
            sat.initialRecord('./data/simResults/satPropError_mento_'+str(noiseLevel)+'_exp'+str(experiment)+'/'+sat.name)
            sat.setRecordProgress()
            
            sats.append(sat) # satnum is index +1
            
        for i in range(0,1):
            print 'sat recording:' +str(i+1)
            sat = sats[i]
            for j in range(0,iterationNum):
                sat.prop(sat.curtruetime,sat.curtruetime+100)
                sat.recordNow()